// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package com.jrsystems.jrbase.user.service;

import com.jrsystems.jrbase.location.vo.LocationVO;
import com.jrsystems.jrbase.user.User;
import com.jrsystems.jrbase.user.UserDao;
import com.jrsystems.jrbase.user.vo.UserSearchCriteria;
import com.jrsystems.jrbase.user.vo.UserVO;

/**
 * @see com.jrsystems.jrbase.user.service.UserService
 */
public class UserServiceImpl
    extends com.jrsystems.jrbase.user.service.UserServiceBase
{

    /**
     * @see com.jrsystems.jrbase.user.service.UserService#saveUser(com.jrsystems.jrbase.user.vo.UserVO)
     */
    protected  com.jrsystems.jrbase.user.vo.UserVO handleSaveUser(com.jrsystems.jrbase.user.vo.UserVO userVO)
        throws java.lang.Exception
    {
    	User user = getUserDao().userVOToEntity(userVO);
    	UserVO uvo;
    	if(userVO.getId() == null){
    		uvo = getUserDao().toUserVO(getUserDao().create(user));
    	}else{
    		getUserDao().update(user);
    		uvo = userVO;
    	}
        // @todo implement protected  com.jrsystems.jrbase.user.vo.UserVO handleSaveUser(com.jrsystems.jrbase.user.vo.UserVO userVO)
        return uvo;
    }

    /**
     * @see com.jrsystems.jrbase.user.service.UserService#deleteUser(com.jrsystems.jrbase.user.vo.UserVO)
     */
    protected  com.jrsystems.jrbase.user.vo.UserVO handleDeleteUser(com.jrsystems.jrbase.user.vo.UserVO userVO)
        throws java.lang.Exception
    {
    	User user = getUserDao().userVOToEntity(userVO);
    	
    	getUserDao().remove(user);
    	
    	return null;
    }

    /**
     * @see com.jrsystems.jrbase.user.service.UserService#getAllUsers()
     */
    protected  com.jrsystems.jrbase.user.vo.UserVO[] handleGetAllUsers()
        throws java.lang.Exception
    {
    	return (UserVO[]) getUserDao().loadAll(UserDao.TRANSFORM_USERVO).toArray();
    }

    /**
     * @see com.jrsystems.jrbase.user.service.UserService#getUsersByStatus(com.jrsystems.jrbase.user.UserStatus)
     */
    protected  com.jrsystems.jrbase.user.vo.UserVO[] handleGetUsersByStatus(com.jrsystems.jrbase.user.UserStatus status)
        throws java.lang.Exception
    {
    	UserSearchCriteria searchCriteria = new UserSearchCriteria();
    	//searchCriteria.set
        // @todo implement protected  com.jrsystems.jrbase.user.vo.UserVO[] handleGetUsersByStatus(com.jrsystems.jrbase.user.UserStatus status)
        throw new java.lang.UnsupportedOperationException("com.jrsystems.jrbase.user.service.UserService.handleGetUsersByStatus(com.jrsystems.jrbase.user.UserStatus status) Not implemented!");
    }

    /**
     * @see com.jrsystems.jrbase.user.service.UserService#getUserDetails(java.lang.String)
     */
    protected  com.jrsystems.jrbase.user.vo.UserVO handleGetUserDetails(java.lang.String username)
        throws java.lang.Exception
    {
    	UserSearchCriteria searchCriteria = new UserSearchCriteria();
        // @todo implement protected  com.jrsystems.jrbase.user.vo.UserVO handleGetUserDetails(java.lang.String username)
        throw new java.lang.UnsupportedOperationException("com.jrsystems.jrbase.user.service.UserService.handleGetUserDetails(java.lang.String username) Not implemented!");
    }

	@Override
	protected LocationVO[] handleGetUserLocation(UserVO userVO)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}